//
//  UIViewController+Alter.m
//  haojia
//
//  Created by 方伟 on 16/5/17.
//  Copyright © 2016年 徐宏飞. All rights reserved.
//

#import "UIViewController+Alter.h"

@implementation UIViewController (Alter)


- (void)showAlertWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles{
    
    //创建一个提示框页面
    //UIAlertControllerStyleAlert 在中间弹出
    //UIAlertControllerStyleActionSheet z在底下弹出
    UIAlertController *alertC = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    
    //出示提示框页面
    //参数1.设置弹出页面的对象
    //参数2.是否有动画
    //参数3.block 板块 弹出完成时的执行block
    [self presentViewController:alertC animated:YES completion:^{
        
    }];
    
    //添加一个确定按钮
    UIAlertAction *alertA = [UIAlertAction actionWithTitle:otherButtonTitles style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        
    }];
    //添加提示按钮
    [alertC addAction:alertA];
    
    
}


- (BOOL)PhoneNumIsvalid:(NSString *)num{
    
    NSString *regex = @"^[1][3578][0-9]{9}$";
    
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    
    return [pred evaluateWithObject:num];
    
}


- (BOOL)passWordCodeIsvalid:(NSString *)num{
    NSString *regex = @"^[a-zA-Z0-9]{6,20}+$";
    
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    
    return [pred evaluateWithObject:num];
    
    
}


- (BOOL)BankCardNumIsvalid:(NSString *)num{
    
    NSString *regex = @"^[0-9]*$";
    
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    
    return [pred evaluateWithObject:num];
    
}




@end



